//---------------------------------------------------------------------------

#ifndef GameH
#define GameH
#include<iostream>
#include "core/Boards.h"
#include <windows.h>
#include <gl/glut.h>
#include <gl/glaux.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;
// keperluan gameplay
enum GameState { startmenu, gameplay, options, help, credits, highscore };
enum ThemeState { classic, unyu };
enum InputState { player1, player2 };

// region kerjaan mp
enum SelectPlayerMode { pvp, pvc, cvc };
enum GreedyChoice { one, two, three };
enum SpeedMode { low, medium, high };
enum BoardSizeMode { eight, ten };
enum GameStatus {playing, red_win, black_win, stop_game, gameLoad};
// endregion kerjaan mp


//gameplay
int turn;
int battleMode;
// int endGame; // 0 untuk
bool enemyFront;
int currentCoin;
int speedCom;
int comLevel;
History mHistory;
string gameFile, statusFile, scoreFile;
bool initGame;

// attributes
GameStatus gameStatus;
GameState gameState;
ThemeState themeState;
// HighScoreState highScoreState;
// region kerjaan mp
InputState inputState;
SelectPlayerMode selectPlayerState;
GreedyChoice greedyChoiceCom1;
GreedyChoice greedyChoiceCom2;
SpeedMode speedMode;
BoardSizeMode boardSizeMode;
// endregion kerjaan mp
Boards myCheckers;
int bidakPressed = 0; // 0 jika tidak ada bidak yang di pilih, 1-24 bila ada bidak yang terpilih sesuai dengan nomor bidaknya
int possibleAreaToMove[1][5];
int boardSize;
int coinSelected;
int lastMove[2];
clock_t begin, end;

// id dari texture tiap-tiap image yang di-draw
GLuint backgroundStartMenu_id;
GLuint bg_gameplay_1;
GLuint bg_gameplay_2;
GLuint papan_1;
GLuint papan_2;

GLuint papanafter_1;
// kerjaan mp
string player1name;
string player2name;
int length;
int length1;
int length2;
GLuint bidak1_after_1;
GLuint bidak2_after_1;
GLuint king1_after_1;
GLuint king2_after_1;
GLuint bidak1_after_2;
GLuint bidak2_after_2;
GLuint king1_after_2;
GLuint king2_after_2;
GLuint papanafter_2;

GLuint posibilitas_1;
GLuint posibilitas_eat_1;
GLuint posibilitas_2;
GLuint posibilitas_eat_2;
GLuint bidak1_1;
GLuint bidak1_2;
GLuint bidak1_eat_1;
GLuint bidak1_eat_2;
GLuint bidak2_1;
GLuint bidak2_2;
GLuint bidak2_eat_1;
GLuint bidak2_eat_2;
// region kerjaan mp
GLuint pvp_id;
GLuint pvc_id;
GLuint cvc_id;
GLuint low_id;
GLuint medium_id;
GLuint high_id;
GLuint byaggressive_id;
GLuint bysave_id;
GLuint hybrid_id;
GLuint eight_id;
GLuint ten_id;

// endregion kerjaan mp
GLuint bidak1_pressed_1;
GLuint bidak1_pressed_2;
GLuint bidak2_pressed_1;
GLuint bidak2_pressed_2;
GLuint bg_highscore;
GLuint bg_options_1;
GLuint bg_options_2;
GLuint bg_options_1_cvc;
GLuint bg_help_1;
GLuint bg_help_2;
GLuint bg_credits_1;
GLuint bg_credits_2;
GLuint king1_1;
GLuint king1_2;
GLuint king1_eat_1;
GLuint king1_eat_2;
GLuint king2_1;
GLuint king2_2;
GLuint king2_eat_1;
GLuint king2_eat_2;
GLuint king1_pressed_1;
GLuint king1_pressed_2;
GLuint king2_pressed_1;
GLuint king2_pressed_2;

GLuint turn_red; // red
GLuint turn_black; // black

// papan kemenangan
GLuint win_black; // black
GLuint win_red; // red

// methods
Boards getBoards();
// melakukan pembacaan file bitmap
GLuint loadBMP(const char * filename);
void initGL();
void loadContent();
void initialize();
float widthRatio(int width, int gameWidth);
float heightRatio(int height, int gameHeight);
void exitKey(unsigned char key, int x, int y);
void keyPressed(int key, int xx, int yy);
void mouseButton(int button, int state, int x, int y);
void updateGamePlay(void);
void drawStartMenu();
void drawBidak();
void drawOptions();
void drawGamePlay();
void drawHighScore();
void draw();
void drawScore();
void drawBoards();
void drawTurn();
void drawBoardsFeatures();
void drawWin();
void initregister();
void newCheckers();

double diffclock(clock_t clock1,clock_t clock2);

bool currentTurn(char);
void playerTurn();
void updateBoards();
void checkersRules();
int getCoinFromMouse(int x, int y);
void clearPossibleArea();
void comAIMovement(int *moveTo, bool);
void confirmSave(); // menentukan apakah akan di save atau tidak sebelum meninggalkan permainan
void playerMovement(int *moveTo);
void comAIMovement(int *moveTo);
int* getAreaFromMouse(int x, int y);
int onDirectionMove(int coin,  int posx, int posy);
int onDirectionKill(int coin,  int posx, int posy);
void initBitmap();
void fillPossibleArea(int coin);
//---------------------------------------------------------------------------
#endif
